package com.bwie.controller;

import com.bwie.pojo.Shop;
import com.bwie.service.ShopService;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import com.bwie.vo.ShopDayDataVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/shop/shop")
public class ShopController {
    @Autowired
    private ShopService shopService;

    /**
     * 商品列表
     * @param pageInfoVo
     * @return
     */
    @PostMapping("/getShopList")
    public R getShopList(
            @RequestBody PageInfoVo pageInfoVo
            ){
        return shopService.getShopList(pageInfoVo);
    }

    /**
     * 商品类型
     * @param typeId
     * @return
     */
    @PostMapping("/getShopType/{typeId}")
    public R getShopType(
        @PathVariable Integer typeId
    ){
        return shopService.getShopType(typeId);
    }

    /**
     * 添加商品
     * @param shop
     * @return
     */
    @PostMapping("/addShop")
    public R addShop(
            @RequestBody Shop shop
            ){
        return shopService.addShop(shop);
    }

    /**
     * 导出
     */
    @GetMapping("/exportExcel")
    public void exprotExcel(){
        shopService.exprotExcel();
    }

    /**
     * 图片上传
     * @param file
     * @return
     */
    @PostMapping("/uploadFile")
    public R uploadFile(
            @RequestPart("file") MultipartFile file
            ){
        return shopService.uploadFile(file);
    }

    /**
     * 修改状态
     * @param shop
     * @return
     */
    @PostMapping("/updateShopStatus")
    public R updateShopStatus(
            @RequestBody Shop shop
    ){
        return shopService.updateShopStatus(shop);
    }

    /**
     * 获取上架下架信息
     * @return
     */
    @PostMapping("/getShopData")
    public R getShopData(){
        return shopService.getShopData();
    }

    /**
     * 饼图，折线，柱状
     * @return
     */
    @PostMapping("/getShopDayData")
    public R getShopDayData(){
        return shopService.getShopDayData();
    }
}
